#include "SceneLoading.h"

SceneLoading::SceneLoading()
	:BaseScene()
{
	m_timeDuring = 100;
	init();
	
}

SceneLoading::~SceneLoading()
{

}

void SceneLoading::processInput()
{

	if (m_input->onKeyDown(DIK_RETURN))
	{
		m_backScene = true;
	}

}

void SceneLoading::init()
{
	m_sp1P = m_resource->load_1p;
	m_sp1P->setPostion(D3DXVECTOR2(20, 40));

	m_spRest = m_resource->load_rest;
	m_spRest->setPostion(D3DXVECTOR2(20, 60));

	m_spHi = m_resource->load_hi;
	m_spHi->setPostion(D3DXVECTOR2(80, 90));

	m_spNumber = m_resource->load_number;
	m_spNumber->setPostion(D3DXVECTOR2(110, 90));

	m_spStage = m_resource->load_stage;
	m_spStage->setPostion(D3DXVECTOR2(100, 130));

	m_spNameStage = m_resource->load_nameStage;
	m_spNameStage->setPostion(D3DXVECTOR2(100, 150));	

}

void SceneLoading::draw()
{
	m_sp1P->draw(m_spriteHandler);
	m_spHi->draw(m_spriteHandler);
	m_spRest->draw(m_spriteHandler);	
	m_spStage->draw(m_spriteHandler);
	m_spNameStage->draw(m_spriteHandler);
	if (m_timeDuring % 10 == 0)
	{
		m_spNumber->draw(m_spriteHandler);
	}
}

void SceneLoading::update(float time)
{
	
	if (m_nextScene)
	{
		SceneManager::getInstance()->createPlayScene();
		m_nextScene = false;
	}

	if (m_backScene)
	{
		SceneManager::getInstance()->loadMenuScene();
		m_backScene = false;
	}

	if (m_timeDuring > 0)
	{
		m_timeDuring--;
	}
	else
	{
		m_nextScene = true;
	}

	
}

void SceneLoading::destroy()
{

}